package com.xzx.shop_front_api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xzx.shop_front_api.entity.Category;
import com.xzx.shop_front_api.mapper.CategoryMapper;
import com.xzx.shop_front_api.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;
    @Override
    public int insertCategory(Category category) {
        return categoryMapper.insert(category);
    }

    @Override
    public Category getCategoryByCateName(String cateName) {
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("cate_name", cateName);
        return categoryMapper.selectOne(queryWrapper);
    }

    @Override
    public List<Category> getAllCategory() {
        return categoryMapper.selectAllCategory();
    }
}
